import { BaseEntity } from '../../base/entity/base';
import { Column, Entity, Index } from 'typeorm';

/**
 * 优惠券信息
 */
@Entity('coupon_info')
export class CouponInfoEntity extends BaseEntity {
  @Index()
  @Column({ comment: '名称' })
  name: string;

  @Column({ comment: '类型', dict: ['满减券', '折扣券', '随机券'], default: 0 })
  type: number;

  @Column({
    comment: '优惠金额',
    type: 'decimal',
    precision: 10,
    scale: 2,
    nullable: true,
  })
  discountAmount: number;

  @Column({
    comment: '折扣比例',
    type: 'decimal',
    precision: 5,
    scale: 2,
    nullable: true,
  })
  discountRatio: number;

  @Column({
    comment: '使用门槛金额',
    type: 'decimal',
    precision: 10,
    scale: 2,
    default: 0,
  })
  thresholdAmount: number;

  @Column({ comment: '发放总量', default: 0 })
  totalQuantity: number;

  @Column({ comment: '剩余数量', default: 0 })
  remainingQuantity: number;

  @Column({ comment: '领取开始时间', nullable: true })
  receiveStartTime: Date;

  @Column({ comment: '领取结束时间', nullable: true })
  receiveEndTime: Date;

  @Column({
    comment: '有效期类型',
    dict: ['固定时间', '领取后天数'],
    default: 0,
  })
  validityType: number;

  @Column({ comment: '有效期天数', nullable: true })
  validityDays: number;

  @Column({ comment: '有效期开始时间', nullable: true })
  validityStartTime: Date;

  @Column({ comment: '有效期结束时间', nullable: true })
  validityEndTime: Date;

  @Column({ comment: '使用说明', type: 'text', nullable: true })
  instructions: string;

  @Index()
  @Column({ comment: '状态', dict: ['未开始', '发放中', '已结束'], default: 0 })
  status: number;
}
